--[[
* MapNotesInstance for MapLib 2.0
* File: MapNotesInstance\MapNotesInstance.lua
* $Revision: 141 $
* $Date: 2007-01-14 10:29:10 +0000 (Sun, 14 Jan 2007) $
* 
* Copyright (c) 2006-2007, Mery (Moritz Metelmann)
* All rights reserved.
* 
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* 
*    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*    * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]--

MapNotesInstance = MapNotesInstance or {};
MapNotesInstance.portals = {};
MapNotesInstance.ZONE = {};
MapNotesInstance.INSTANCE_NORMAL = { file = MapLib.PATH.."\\Icons\\INSTANCE_NORMAL", size = 20 };
MapNotesInstance.INSTANCE_BG = { file = MapLib.PATH.."\\Icons\\INSTANCE_BG", size = 20 };
MapNotesInstance.INSTANCE_LOCKOUT = { file = MapLib.PATH.."\\Icons\\INSTANCE_LOCKOUT", size = 20 };
MapNotesInstance.INSTANCE_HEROIC = { file = MapLib.PATH.."\\Icons\\INSTANCE_HEROIC", size = 20 };
MapNotesInstance.INSTANCE_WHITE = { file = "Interface\\AddOns\\MapNotesInstance\\Icons\\INSTANCE_WHITE", size = 20 };

local L = MapNotesInstance.Localization;
local L_ML = MapLib.Localization;

MapNotesInstance.ProcessMapClick = function(adj_x, adj_y)
	return;
end;

MapNotesInstance.UpdateMapHighligh = function(adj_x, adj_y)
	return;
end;

MapNotesInstance.GetNumMapOverlays = function()
	return 0;
end;

MapNotesInstance.GetMapOverlayInfo = function(index)
	return;
end;

MapNotesInstance.GetPlayerMapPosition = function(unit)
	return 0, 0;
end;

MapNotesInstance.GetCorpseMapPosition = function()
	return 0, 0;
end;

MapNotesInstance.GetDeathReleasePosition = function()
	return 0, 0;
end;

MapNotesInstance.ZONE.GetPlayerMapPosition = function(unit)
	local x, y = GetPlayerMapPosition(unit);
	local mapInfo = MapLib.mapInfo[MapLib.mapShown];
	local zx = (x - mapInfo.xoffset) / mapInfo.scale;
	local zy = (y - mapInfo.yoffset) / mapInfo.scale;
	if (zx > 0 and zx < 1 and zy > 0 and zy < 1) then
		return zx, zy;
	else
		return 0, 0;
	end;
end;

MapNotesInstance.ZONE.GetCorpseMapPosition = function()
	local x, y = GetCorpseMapPosition();
	local mapInfo = MapLib.mapInfo[MapLib.mapShown];
	local zx = (x - mapInfo.xoffset) / mapInfo.scale;
	local zy = (y - mapInfo.yoffset) / mapInfo.scale;
	if (zx > 0 and zx < 1 and zy > 0 and zy < 1) then
		return zx, zy;
	else
		return 0, 0;
	end;
end;

MapNotesInstance.ZONE.GetDeathReleasePosition = function()
	local x, y = GetDeathReleasePosition();
	local mapInfo = MapLib.mapInfo[MapLib.mapShown];
	local zx = (x - mapInfo.xoffset) / mapInfo.scale;
	local zy = (y - mapInfo.yoffset) / mapInfo.scale;
	if (zx > 0 and zx < 1 and zy > 0 and zy < 1) then
		return zx, zy;
	else
		return 0, 0;
	end;
end;

MapNotesInstance.GetNumInstancePortals = function()
	if (MapNotesInstance.portals[MapLib.mapShown]) then
		return #MapNotesInstance.portals[MapLib.mapShown];
	end;
	return 0;
end;

MapNotesInstance.GetInstancePortal = function(index)
	local note = MapNotesInstance.portals[MapLib.mapShown][index];
	id = strjoin("|", MapLib.mapShown, index);
	return id, note[1], note[4], note[5], note[6], note[7], note[8], note[9];
end;

MapNotesInstance.GetInstanceTooltip = function(id, title)
	local zone, index = strsplit("|", id);
	index = tonumber(index);
	local note = MapNotesInstance.portals[zone][index];
--	return note[1], note[2], note[3], note[4], note[5], note[6], note[7], note[8];

	MapLibBlizzardPOITooltipIcon:SetTexture(note[4].file); 
	MapLibBlizzardPOITooltipIcon:SetTexCoord(0, 1, 0, 1);
	MapLibBlizzardPOITooltipHeader:SetText(note[1]);
	local height = 25;
	if (note[2] and note[2]~="") then
		MapLibBlizzardPOITooltipDescription:SetText(note[2]);
		MapLibBlizzardPOITooltipDescription:Show();
		height = 41;
	else
		MapLibBlizzardPOITooltipDescription:Hide();
	end;
	if (note[3] and note[3]~="") then
		MapLibBlizzardPOITooltipDescription2:SetText(note[3]);
		MapLibBlizzardPOITooltipDescription2:Show();
		height = 57;
	else
		MapLibBlizzardPOITooltipDescription2:Hide();
	end;	
	MapLibBlizzardPOITooltip:SetHeight(height);

	return MapLibBlizzardPOITooltip;
end;

MapNotesInstance.GetBasicInstancePortalInfo = function(id)
	local zone, index = strsplit("|", id);
	index = tonumber(index);
	local note = MapNotesInstance.portals[zone][index];
	return note[1], zone, note[4], note[5], note[6];
end;

MapNotesInstance.POI_OnClick = function(poi)
	local zone, index = strsplit("|", poi.id);
	index = tonumber(index);
	MapLib.SetMapToID(MapNotesInstance.portals[zone][index][10]);
end;

local submenu = {
	{text = L["White Portal"], texture = MapNotesInstance.INSTANCE_WHITE, style = "MNI_WHITE", default = true},
	{text = L["Normal Instance"], texture = MapNotesInstance.INSTANCE_NORMAL, style = "MNI_NORMAL", default = true},
	{text = L["Instance with 'Heroic' mode"], texture = MapNotesInstance.INSTANCE_HEROIC, style = "MNI_HEROIC", default = true},
	{text = L["Raid Instance (Lockout)"], texture = MapNotesInstance.INSTANCE_LOCKOUT, style = "MNI_LOCKOUT", default = true},
	{text = L["Battleground"], texture = MapNotesInstance.INSTANCE_BG, style = "MNI_BG", default = true},
}

MapLib.RegisterZone("EK_BM", L["Blackrock Mountain"], "CO_EK", "EK_BS", "ZONE", "Interface\\AddOns\\MapNotesInstance\\BlackrockMountain\\BlackrockMountain", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.ZONE.GetPlayerMapPosition, MapNotesInstance.ZONE.GetCorpseMapPosition, MapNotesInstance.ZONE.GetDeathReleasePosition, 0.031997394976, 0.466791110484, 0.646907210349);

MapLib.RegisterZone("KA*BD", L["Blackfathom Deeps"], "CO_KA", "KA_FE", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\BlackfathomDeeps\\BlackfathomDeeps", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("KA*DM", L["Dire Maul"], "CO_KA", "KA_FE", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\DireMaul\\DireMaul", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("KA*MA", L["Maraudon"], "CO_KA", "KA_DE", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\Maraudon\\Maraudon", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("KA*OL", L["Onyxia's Lair"], "CO_KA", "KA_DW", "INSTANCE_LOCKOUT", "Interface\\AddOns\\MapNotesInstance\\OnyxiasLair\\OnyxiasLair", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("KA*RC", L["Ragefire Chasm"], "CO_KA", "KA_OG", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\RagefireChasm\\RagefireChasm", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("KA*RD", L["Razorfen Downs"], "CO_KA", "KA_BA", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\RazorfenDowns\\RazorfenDowns", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("KA*RK", L["Razorfen Kraul"], "CO_KA", "KA_BA", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\RazorfenKraul\\RazorfenKraul", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("KA*RU", L["Ruins of Ahn'Qiraj"], "CO_KA", "KA_SI", "INSTANCE_LOCKOUT", "Interface\\AddOns\\MapNotesInstance\\RuinsOfAhnQiraj\\RuinsOfAhnQiraj", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("KA*AQ", L["Temple of Ahn'Qiraj"], "CO_KA", "KA_SI", "INSTANCE_LOCKOUT", "Interface\\AddOns\\MapNotesInstance\\TempleOfAhnQiraj\\TempleOfAhnQiraj", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("KA*WC", L["Wailing Caverns"], "CO_KA", "KA_BA", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\WailingCaverns\\WailingCaverns", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("KA*ZF", L["Zul'Farrak"], "CO_KA", "KA_TA", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\ZulFarrak\\ZulFarrak", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);

MapLib.RegisterZone("EK*BD", L["Blackrock Depths"], "CO_EK", "EK_BM", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\BlackrockDepths\\BlackrockDepths", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("EK*BW", L["Blackwing Lair"], "CO_EK", "EK_BM", "INSTANCE_LOCKOUT", "Interface\\AddOns\\MapNotesInstance\\BlackwingLair\\BlackwingLair", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("EK*BS", L["Blackrock Spire"], "CO_EK", "EK_BM", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\BlackrockSpire\\BlackrockSpire", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("EK*GR", L["Gnomeregan"], "CO_EK", "EK_DM", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\Gnomeregan\\Gnomeregan", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("EK*MC", L["Molten Core"], "CO_EK", "EK_BM", "INSTANCE_LOCKOUT", "Interface\\AddOns\\MapNotesInstance\\MoltenCore\\MoltenCore", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("EK*NA", L["Naxxramas"], "CO_EK", "EK_EP", "INSTANCE_LOCKOUT", "Interface\\AddOns\\MapNotesInstance\\Naxxramas\\Naxxramas", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("EK*SK", L["The Stockade"], "CO_EK", "EK_SW", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\TheStockade\\TheStockade", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("EK*SM", L["Scarlet Monastery"], "CO_EK", "EK_TG", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\ScarletMonastery\\ScarletMonastery", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("EK*SO", L["Scholomance"], "CO_EK", "EK_WP", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\Scholomance\\Scholomance", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("KA*SK", L["Shadowfang Keep"], "CO_KA", "EK_SF", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\ShadowfangKeep\\ShadowfangKeep", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("EK*SH", L["Stratholme"], "CO_EK", "EK_EP", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\Stratholme\\Stratholme", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("EK*ST", L["Temple of Atal'Hakkar"], "CO_EK", "EK_SS", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\SunkenTemple\\SunkenTemple", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("EK*VC", L["The Deadmines"], "CO_EK", "EK_WF", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\TheDeadmines\\TheDeadmines", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("EK*UL", L["Uldaman"], "CO_EK", "EK_BA", "INSTANCE_NORMAL", "Interface\\AddOns\\MapNotesInstance\\Uldaman\\Uldaman", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("EK*ZG", L["Zul'Gurub"], "CO_EK", "EK_SV", "INSTANCE_LOCKOUT", "Interface\\AddOns\\MapNotesInstance\\ZulGurub\\ZulGurub", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);

MapLib.RegisterZone("OL*HR", L["Hellfire Ramparts"], "CO_OL", "OL_HP", "INSTANCE_HEROIC", "Interface\\AddOns\\MapNotesInstance\\HellfireRamparts\\HellfireRamparts", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("OL*ML", L["Magtheridon's Lair"], "CO_OL", "OL_HP", "INSTANCE_LOCKOUT", "Interface\\AddOns\\MapNotesInstance\\MagtheridonsLair\\MagtheridonsLair", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("OL*BF", L["The Blood Furnace"], "CO_OL", "OL_HP", "INSTANCE_HEROIC", "Interface\\AddOns\\MapNotesInstance\\TheBloodFurnace\\TheBloodFurnace", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("OL*SH", L["The Shattered Halls"], "CO_OL", "OL_HP", "INSTANCE_HEROIC", "Interface\\AddOns\\MapNotesInstance\\TheShatteredHalls\\TheShatteredHalls", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("OL*SP", L["The Slave Pens"], "CO_OL", "OL_ZM", "INSTANCE_HEROIC", "Interface\\AddOns\\MapNotesInstance\\TheSlavePens\\TheSlavePens", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("OL*SV", L["The Steamvault"], "CO_OL", "OL_ZM", "INSTANCE_HEROIC", "Interface\\AddOns\\MapNotesInstance\\TheSteamvault\\TheSteamvault", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);
MapLib.RegisterZone("OL*UB", L["The Underbog"], "CO_OL", "OL_ZM", "INSTANCE_HEROIC", "Interface\\AddOns\\MapNotesInstance\\TheUnderbog\\TheUnderbog", MapNotesInstance.ProcessMapClick, MapNotesInstance.UpdateMapHighligh, MapNotesInstance.GetNumMapOverlays, MapNotesInstance.GetMapOverlayInfo, MapNotesInstance.GetPlayerMapPosition, MapNotesInstance.GetCorpseMapPosition, MapNotesInstance.GetDeathReleasePosition);

-- No need for a variables loaded check since MapLib is in another addon anyway.
MapLib.POI.RegisterForPOI("MN_INSTANCE", L["Instance Portals"], 3, submenu, MapNotesInstance.GetNumInstancePortals, MapNotesInstance.GetInstancePortal, MapNotesInstance.GetInstanceTooltip, false);

MapNotesInstance.portals["KA_AS"] = {};
table.insert(MapNotesInstance.portals["KA_AS"], {L["Warsong Gulch"], L["Alliance Portal"], "", MapNotesInstance.INSTANCE_BG, 0.61657106876373, 0.84477168321609, "MNI_BG", 1, MapNotesInstance.POI_OnClick, "KA_WG"});

MapNotesInstance.portals["KA_BA"] = {};
table.insert(MapNotesInstance.portals["KA_BA"], {L["Warsong Gulch"], L["Horde Portal"], "", MapNotesInstance.INSTANCE_BG, 0.46513694524765, 0.085588574409485, "MNI_BG", 1, MapNotesInstance.POI_OnClick, "KA_WG"});

MapNotesInstance.portals["EK_AH"] = {};
table.insert(MapNotesInstance.portals["EK_AH"], {L["Arathi Basin"], L["Alliance Portal"], "", MapNotesInstance.INSTANCE_BG, 0.46258369088173, 0.44106474518776, "MNI_BG", 1, MapNotesInstance.POI_OnClick, "EK_AB"});
table.insert(MapNotesInstance.portals["EK_AH"], {L["Arathi Basin"], L["Horde Portal"], "", MapNotesInstance.INSTANCE_BG, 0.73344820737839, 0.28309968113899, "MNI_BG", 1, MapNotesInstance.POI_OnClick, "EK_AB"});

MapNotesInstance.portals["EK_AM"] = {};
table.insert(MapNotesInstance.portals["EK_AM"], {L["Alterac Valley"], L["Alliance Portal"], "", MapNotesInstance.INSTANCE_BG, 0.34377375245094, 0.75045508146286, "MNI_BG", 1, MapNotesInstance.POI_OnClick, "EK_AV"});
table.insert(MapNotesInstance.portals["EK_AM"], {L["Alterac Valley"], L["Horde Portal"], "", MapNotesInstance.INSTANCE_BG, 0.666649520397, 0.51307028532028, "MNI_BG", 1, MapNotesInstance.POI_OnClick, "EK_AV"});

MapNotesInstance.portals["EK_BA"] = {};
table.insert(MapNotesInstance.portals["EK_BA"], {L["Uldaman"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.3519169986248, 0.1053009107708, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK*UL"});
table.insert(MapNotesInstance.portals["EK_BA"], {L["Uldaman"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.6776185631752, 0.4398635327816, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK*UL"});

MapNotesInstance.portals["EK_BM"] = {};
table.insert(MapNotesInstance.portals["EK_BM"], {L["Blackrock Spire"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.58687172163264, 0.59815522734394, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK*BS"});
table.insert(MapNotesInstance.portals["EK_BM"], {L["Blackwing Lair"], "", "", MapNotesInstance.INSTANCE_LOCKOUT, 0.57725038619200, 0.77015656931143, "MNI_LOCKOUT", 1, MapNotesInstance.POI_OnClick, "EK*BW"});
table.insert(MapNotesInstance.portals["EK_BM"], {L["Molten Core"], "", "", MapNotesInstance.INSTANCE_LOCKOUT, 0.42855263211657, 0.57866478448906, "MNI_LOCKOUT", 1, MapNotesInstance.POI_OnClick, "EK*MC"});
table.insert(MapNotesInstance.portals["EK_BM"], {L["Blackrock Depths"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.33318675025135, 0.16864458217722, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK*BD"});

MapNotesInstance.portals["EK*BD"] = {};
table.insert(MapNotesInstance.portals["EK*BD"], {L["Blackrock Mountain"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.33932135728542, 0.79640718562874, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_BM"});
table.insert(MapNotesInstance.portals["EK*BD"], {L["Molten Core"], "", "", MapNotesInstance.INSTANCE_LOCKOUT, 0.58682634730538, 0.32485029940119, "MNI_LOCKOUT", 1, MapNotesInstance.POI_OnClick, "EK*MC"});

MapNotesInstance.portals["EK*BW"] = {};
table.insert(MapNotesInstance.portals["EK*BW"], {L["Blackrock Mountain"], "", "", MapNotesInstance.INSTANCE_LOCKOUT, 0.62974051896207, 0.55838323353293, "MNI_LOCKOUT", 1, MapNotesInstance.POI_OnClick, "EK_BM"});

MapNotesInstance.portals["EK_EP"] = {};
table.insert(MapNotesInstance.portals["EK_EP"], {L["Naxxramas"], "", "", MapNotesInstance.INSTANCE_LOCKOUT, 0.39934217929840, 0.25813591480255, "MNI_LOCKOUT", 1, MapNotesInstance.POI_OnClick, "EK*"});
table.insert(MapNotesInstance.portals["EK_EP"], {L["Stratholme"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.31479337811470, 0.15787711739540, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK*SH"});
table.insert(MapNotesInstance.portals["EK_EP"], {L["Stratholme"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.30220246315002, 0.15786784887314, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK*SH"});
table.insert(MapNotesInstance.portals["EK_EP"], {L["Stratholme"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.48237374424934, 0.21891403198242, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK*SH"});

MapNotesInstance.portals["EK*MC"] = {};
table.insert(MapNotesInstance.portals["EK*MC"], {L["Blackrock Depths"], "", "", MapNotesInstance.INSTANCE_LOCKOUT, 0.18962075848303, 0.21706586826347, "MNI_LOCKOUT", 1, MapNotesInstance.POI_OnClick, "EK*BD"});

MapNotesInstance.portals["EK*SH"] = {};
table.insert(MapNotesInstance.portals["EK*SH"], {L_ML["Eastern Plaguelands"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.49900199600798, 0.95059880239520, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_EP"});
table.insert(MapNotesInstance.portals["EK*SH"], {L_ML["Eastern Plaguelands"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.52994011976047, 0.95059880239520, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_EP"});
table.insert(MapNotesInstance.portals["EK*SH"], {L_ML["Eastern Plaguelands"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.72055888223552, 0.73203592814371, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_EP"});
table.insert(MapNotesInstance.portals["EK*SH"], {L["(Unknown)"], L["(not yet implemented)"], "", MapNotesInstance.INSTANCE_LOCKOUT, 0.51397205588822, 0.30538922155688, "MNI_LOCKOUT", 1, MapNotesInstance.POI_OnClick, "EK*"});

MapNotesInstance.portals["EK*SM"] = {};
table.insert(MapNotesInstance.portals["EK*SM"], {L_ML["Tirisfal Glades"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.44510978043912, 0.70359281437125, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_TG"});
table.insert(MapNotesInstance.portals["EK*SM"], {L_ML["Tirisfal Glades"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.55289421157684, 0.66616766467065, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_TG"});
table.insert(MapNotesInstance.portals["EK*SM"], {L_ML["Tirisfal Glades"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.60578842315369, 0.65419161676646, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_TG"});
table.insert(MapNotesInstance.portals["EK*SM"], {L_ML["Tirisfal Glades"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.65169660678642, 0.70508982035928, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_TG"});

MapNotesInstance.portals["EK*SO"] = {};
table.insert(MapNotesInstance.portals["EK*SO"], {L_ML["Western Plaquelands"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.43712574850299, 0.41017964071856, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_WP"});

MapNotesInstance.portals["EK_SW"] = {};
table.insert(MapNotesInstance.portals["EK_SW"], {L["The Stockade"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.39769306778908, 0.54185521602631, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK*SK"});

MapNotesInstance.portals["EK*SK"] = {};
table.insert(MapNotesInstance.portals["EK*SK"], {L_ML["Stormwind"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.50000399201597, 0.79341317365269, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_SW"});

MapNotesInstance.portals["EK_SV"] = {};
table.insert(MapNotesInstance.portals["EK_SV"], {L["Zul'Gurub"], "", "", MapNotesInstance.INSTANCE_LOCKOUT, 0.54056697083878, 0.17571677267551, "MNI_LOCKOUT", 1, MapNotesInstance.POI_OnClick, "EK*ZG"});

MapNotesInstance.portals["EK_TG"] = {};
table.insert(MapNotesInstance.portals["EK_TG"], {L["Scarlet Monastery"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.84854525327682, 0.30562463402748, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK*SM"});
table.insert(MapNotesInstance.portals["EK_TG"], {L["Scarlet Monastery"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.85336476564407, 0.30539754033089, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK*SM"});
table.insert(MapNotesInstance.portals["EK_TG"], {L["Scarlet Monastery"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.85646349191666, 0.31680428981781, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK*SM"});
table.insert(MapNotesInstance.portals["EK_TG"], {L["Scarlet Monastery"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.85309010744095, 0.32207107543945, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK*SM"});

MapNotesInstance.portals["EK*UL"] = {};
table.insert(MapNotesInstance.portals["EK*UL"], {L_ML["Badlands"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.72355289421157, 0.70359281437125, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_BA"});
table.insert(MapNotesInstance.portals["EK*UL"], {L_ML["Badlands"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.36027944111776, 0.68113772455089, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_BA"});

MapNotesInstance.portals["EK*VC"] = {};
table.insert(MapNotesInstance.portals["EK*VC"], {L_ML["Westfall"], L["Entrance"], "", MapNotesInstance.INSTANCE_NORMAL, 0.14371257485029, 0.13023952095808, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_WF"});
table.insert(MapNotesInstance.portals["EK*VC"], {L_ML["Westfall"], L["Exit (only)"], "", MapNotesInstance.INSTANCE_NORMAL, 0.92415169660678, 0.33682634730538, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK_WF"});

MapNotesInstance.portals["EK_WP"] = {};
table.insert(MapNotesInstance.portals["EK_WP"], {L["Scholomance"], "", "", MapNotesInstance.INSTANCE_NORMAL, 0.69033855199814, 0.72888427972794, "MNI_NORMAL", 1, MapNotesInstance.POI_OnClick, "EK*SO"});

MapNotesInstance.portals["EK*ZG"] = {};
table.insert(MapNotesInstance.portals["EK*ZG"], {L_ML["Stranglehorn Vale"], "", "", MapNotesInstance.INSTANCE_LOCKOUT, 0.28343313373253, 0.49251497005988, "MNI_LOCKOUT", 1, MapNotesInstance.POI_OnClick, "EK_SV"});

MapNotesInstance.portals["OL_HP"] = {};
table.insert(MapNotesInstance.portals["OL_HP"], {L["The Blood Furnace"], "", "", MapNotesInstance.INSTANCE_HEROIC, 0.4597351551056, 0.5184600353241, "MNI_HEROIC", 1, MapNotesInstance.POI_OnClick, "OL*BF"});
table.insert(MapNotesInstance.portals["OL_HP"], {L["The Shattered Halls"], "", "", MapNotesInstance.INSTANCE_HEROIC, 0.47482135891814, 0.52032166719437, "MNI_HEROIC", 1, MapNotesInstance.POI_OnClick, "OL*SH"});
table.insert(MapNotesInstance.portals["OL_HP"], {L["Hellfire Ramparts"], "", "", MapNotesInstance.INSTANCE_HEROIC, 0.47593802213669, 0.53595024347305, "MNI_HEROIC", 1, MapNotesInstance.POI_OnClick, "OL*HR"});
table.insert(MapNotesInstance.portals["OL_HP"], {L["Magtheridon's Lair"], "", "", MapNotesInstance.INSTANCE_LOCKOUT, 0.47552615404129, 0.52057558298111, "MNI_LOCKOUT", 1, MapNotesInstance.POI_OnClick, "OL*ML"});
